<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--用户数据-->
      <el-col :span="24" :xs="24">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
          <el-form-item label="真实姓名" prop="realName">
            <el-input
              v-model="queryParams.realName"
              placeholder="请输入姓名"
              clearable
              size="medium"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="身份证号" prop="identityCard">
            <el-input
              v-model="queryParams.identityCard"
              placeholder="请输入身份证号"
              clearable
              size="medium"
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="状态" prop="authenticity">
            <el-select
              v-model="queryParams.authenticity"
              placeholder="真实状态"
              clearable
              size="medium"
              style="width: 240px"
            >
              <!-- <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              /> -->
              <el-option label="全部" value=""></el-option>
              <el-option label="真实" value="1"></el-option>
              <el-option label="不真实" value="0"></el-option>
            </el-select>
          </el-form-item>
         <!--<el-form-item label="创建时间">
            <el-date-picker
              v-model="dateRange"
              size="small"
              style="width: 240px"
              value-format="yyyy-MM-dd"
              type="daterange"
              range-separator="-"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker> 
          </el-form-item>-->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="medium" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="medium" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

  

        <el-table v-loading="loading" :data="identityList">
          <el-table-column label="编号" align="left" key="id" prop="id"  width="150"/>
          <el-table-column label="姓名" align="left" key="realName" prop="realName"  :show-overflow-tooltip="true" />
          <el-table-column label="身份证号" align="left" key="identityCard" prop="identityCard" :show-overflow-tooltip="true" />
          <el-table-column label="是否真实" align="center" prop="authenticity" :formatter="authenticity"/>
        
          <el-table-column label="创建时间" align="center" prop="createdAt">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createdAt) }}</span>
            </template>
          </el-table-column>
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { listidentity } from "@/api/identity/query";
import { getToken } from "@/utils/auth";

export default {
  name: "identity",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      identityList: null,
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        realName: undefined,
        identityCard: undefined,
        authenticity: undefined
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listidentity(this.queryParams).then(response => {
          this.identityList = response.data.tableData;
          this.total = response.data.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.page = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
     // 菜单状态字典翻译
     authenticity(row, column) {
      
      //return this.selectDictLabel(this.statusOptions, row.status);
      //alert(row.status);
      let status = row.authenticity;
      switch (status) {
        case 1:
          status = "真实";
          break;
        case 0:
          status = "不真实";
          break;
      }
      return status;
    },
  }
};
</script>